<!DOCTYPE html>
<html>
<head>
    <title>管理员登录</title>
    <script>
        async function handleLogin(e) {
            e.preventDefault();
            const formData = new FormData(e.target);
            const response = await fetch('/api/sessions', {
                method: 'POST',
                body: JSON.stringify({
                    password: formData.get('password')
                }),
                headers: {
                    'Content-Type': 'application/json'
                }
            });
            
            if (response.ok) {
                window.location.href = '/admin/dashboard';
            } else {
                alert('登录失败');
            }
        }
    </script>
</head>
<body>
    <h1>管理员登录</h1>
    <form onsubmit="handleLogin(event)">
        <input type="password" name="password" placeholder="密码" required><br>
        <button type="submit">登录</button>
    </form>
    <p>
        <a href="/">返回首页</a>
    </p>
</body>
</html>
